package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice.model.CourseScriptType;
import com.sooncode.project.focusservice.service.CourseSctiptTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("courseScriptType")
public class CourseScriptTypeController {
    @Autowired
    private CourseSctiptTypeService service;
    @PostMapping("courseScriptType")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }

    @PutMapping("courseScriptType")
    public boolean modify(@RequestParam String id,Map map){
        return service.modify(id,map);
    }

    @DeleteMapping("courseScriptType")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("courseScriptTypes")
    public Page<CourseScriptType> getPageList(@RequestParam int pageSize, @RequestParam int pageIndex, @RequestParam Map map){
        map.remove("pageSize");
        map.remove("pageIndex");
        return service.getPageList(pageSize,pageIndex-1,map);
    }
    @GetMapping("courseScriptTypeList")
    public List<CourseScriptType> getCourseScriptTypeList(){
        return service.getList();
    }
}
